<?php
/**
 * Gets this weeks reservations report
 */

// get data for report
$rmDate = new RM_Date();
$sevenDaysFromNow = $rmDate->dateAdd(Date("Y-m-d"),7);

// define the filter for the data we want to return...
$filter[] = array(
    'field' => 'start_datetime',
    'data' => array(
        'type' => 'date',
        'value' => date("Y-m-d"),
        'comparison' => 'gt'
     )
);
$filter[] = array(
    'field' => 'start_datetime',
    'data' => array(
        'type' => 'date',
        'value' => $sevenDaysFromNow,
        'comparison' => 'lt'
    )
);
$filters[] = array(
    'field' => 'confirmed',
    'data' => array(
        'type' => 'numeric',
        'value' => 1,
        'comparison' => 'eq'
    )
);

// reservation data
$reservationsDAO = new RM_ReservationDetails();
$reservations = $reservationsDAO->getAll(null,null,null,$filter);

$total = count($reservations);

?>

<style type="text/css">
<!--
body{
	font-family:Arial,Helvetica,sans-serif;
}
.tableheading{
	font-weight: bold;
}
.rm_report_text_body {
	margin-left: 20px;
	margin-right: 20px;
	font-size: 12px;
}
.row0 {
    background-color: #ffffff;
}

.row1 {
    background-color: #f0f0f0;
}

-->
</style>

<div class="rm_report_text_body">
    <b>This Weeks Confirmed Reservations (includes blocks)</b><br/>
    <hr>
    Total Reservations: <b><?php echo $total;?></b><br/><br/>
    <table width="100%" border="0" cellpadding="2" cellspacing="0">
        <tr>
            <th><b>Reservation ID</b></th>
            <th><b>Start Date</b></th>
            <th><b>End Date</b></th>
            <th><b>Unit ID</b></th>
            <th><b>Unit Name</b></th>
            <th><b>Customer Name</b></th>
            <th><b>Adults</b></th>
            <th><b>Children</b></th>
            <th><b>Infants</b></th>
            <th><b>Total</b></th>
        </tr>
    <?php
    $rowclass = 0;
    foreach($reservations as $reservation){
        ?>
        <tr class="row<?php echo $rowclass; ?>">
            <td><?php echo $reservation['reservation_id'];?></td>
            <td><?php echo $reservation['start_datetime'];?></td>
            <td><?php echo $reservation['end_datetime'];?></td>
            <td><?php echo $reservation['unit_id'];?></td>
            <td><?php echo $reservation['name'];?></td>
            <td><?php echo $reservation['last_name'];?></td>
            <td><?php echo $reservation['adults'];?></td>
            <td><?php echo $reservation['children'];?></td>
            <td><?php echo $reservation['infants'];?></td>
            <td><?php echo $reservation['total_price'];?></td>
        </tr>
        <?php
        $rowclass = 1 - $rowclass;
    }
    ?>
    </table>
</div>